home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / client / include / lgobject.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  5.6 KB  |  260 lines

  1. #ifndef _LGOBJECT_H_
  2. #define _LGOBJECT_H_
  3. /*
  4.  *   $RCSfile: lgobject.h,v $  
  5.  *   $Revision: 1.1.1.1 $  
  6.  *   $Date: 1996/05/04 21:55:20 $      
  7.  */ 
  8. /**********************************************************************
  9. * EXODUS Database Toolkit Software
  10. * Copyright (c) 1991 Computer Sciences Department, University of
  11. *                    Wisconsin -- Madison
  12. * All Rights Reserved.
  13. *
  14. * Permission to use, copy, modify and distribute this software and its
  15. * documentation is hereby granted, provided that both the copyright
  16. * notice and this permission notice appear in all copies of the
  17. * software, derivative works or modified versions, and any portions
  18. * thereof, and that both notices appear in supporting documentation.
  19. *
  20. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  21. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  22. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  23. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  24. *
  25. * The EXODUS Project Group requests users of this software to return 
  26. * any improvements or extensions that they make to:
  27. *
  28. *   EXODUS Project Group 
  29. *     c/o David J. DeWitt and Michael J. Carey
  30. *   Computer Sciences Department
  31. *   University of Wisconsin -- Madison
  32. *   Madison, WI 53706
  33. *
  34. *     or exodus@cs.wisc.edu
  35. *
  36. * In addition, the EXODUS Project Group requests that users grant the 
  37. * Computer Sciences Department rights to redistribute these changes.
  38. **********************************************************************/
  39.  
  40.  
  41.  
  42. /*
  43.  * Leaf node format.
  44.  */
  45. typedef char  *LFNODE;     /* actual data bytes in leaf */
  46.  
  47.  
  48. /*
  49.  * Enumeration type for object-enlarging large object operations.
  50.  */
  51. typedef enum {INSERT, APPEND} OBJOP;
  52.  
  53.  
  54. /*
  55.  * ------- OPERATION STATE STUFF --------
  56.  */
  57.  
  58.  
  59. /*
  60.  *    define traversal stack entry
  61.  *    
  62.  *  The shared field indicates if the pointer to this page had
  63.  *    the share flag set.
  64.  */
  65. typedef struct {
  66.  
  67.     PID            pid;
  68.     GROUPLINK    *nodeLink;
  69.     LGNODE        *nodePtr;
  70.     SLOTINDEX    slotIndex;
  71.     int            dangerCount;
  72.     SLOTINDEX    rootSlot;
  73.     BOOL        dangerFlag;
  74.     BOOL        shared;        /* indicates share bit set on ptr to this node*/
  75.     short        flags;
  76.  
  77. } TSTACKENT;
  78.  
  79.  
  80. /*
  81.  *    define the state of root on slotted page or not
  82.  */
  83. #define LG_SLOTROOT        0x1
  84.  
  85.  
  86. /*
  87.  *    define the maximum depth of the traversal stack
  88.  */
  89. #ifdef LGTESTING
  90. #    define TSTACKSIZE  100         /* maximum stack size needed */
  91. #else
  92. #    define TSTACKSIZE  5         /* maximum stack size needed */
  93. #endif
  94.  
  95.  
  96. /*
  97.  * Traversal path stack and related information.
  98.  */
  99. typedef struct {
  100.  
  101.     int                top; 
  102.     TSTACKENT        stack[TSTACKSIZE];
  103.  
  104. } TSTACK;
  105.  
  106.  
  107.  
  108.  
  109. typedef enum {LEFTPATH, RIGHTPATH} PATHTYPE;
  110.  
  111. typedef enum {NONE, CURRENT, KID1, KID2} WHICHNODE;
  112.  
  113. typedef enum {COLLAPSE, RESHUFFLE, MERGE, LCA_MERGE, LEAFSTUFF} LASTSTEP;
  114.  
  115.  
  116.  
  117.  
  118. /*
  119.  * Structure and macro for maintaining page lists.
  120.  */
  121. typedef struct {
  122.  
  123.    int            numPages;    /* number of pages currently in list */
  124.    int            maxPages;    /* maximum number of pages list can hold */
  125.    int            numBytes;    /* sum of byte counts currently in list */
  126.    CHUNKPAGE    *pages;      /* list of descriptors for pages */
  127.  
  128. } PAGELIST;
  129.  
  130. #define FREELIST(pgList)                         \
  131.     if((pgList)->pages != NULL) {\
  132.         free((char*)(pgList)->pages);  (pgList)->pages = NULL;\
  133.     }
  134.  
  135.  
  136.  
  137. #ifdef JUNK
  138.  
  139.  
  140. /*
  141.  * Array of operation state records and its free list.
  142.  */
  143.  
  144. #define OPTABLESIZE 40
  145.  
  146.  
  147. typedef struct opRecord {
  148.  
  149.     PID               rootPid;      /* large object's root page id */
  150.     LGNODE            *rootPtr;        /* indirect buffer ptr for root */
  151.     int               start;        /* starting offset for desired bytes */
  152.     int               length;       /* length of desired range of bytes */
  153.     int               bfGroup;      /* buffer group for accessing data */
  154.     PAGELIST          leafPages;    /* pageList of relevant leaf pages */
  155.     struct opRecord   *nextFree;    /* next free opRecord in table */
  156.  
  157. } OPRECORD;
  158.  
  159. OPRECORD   OpTable[OPTABLESIZE];
  160.  
  161. OPRECORD   *FreeOp;       /* pointer to first free opTable entry */
  162.  
  163.  
  164. #endif
  165.  
  166.  
  167. /*
  168.  *    LGNODELIST is used in destroying versioned large objects.  It
  169.  *    is a list element containing page id's for nodes.  
  170.  */
  171. typedef    struct {
  172.     LISTELEMENT        list;    /* for storing on lists         */
  173.     LISTELEMENT        hash;    /* for storing in a hash table    */
  174.  
  175.     PID                pid;
  176.     SLOTINDEX        slot;
  177. } LGNODELIST;
  178.  
  179.  
  180.  
  181. #define LGNODEHASHTABLESIZE 1024
  182.  
  183. /*
  184.  *    LGNODEHASHTABLE is a hash table for LGNODELIST elements keyed
  185.  *    on the pid and slot, but hashed only on the pid.page
  186.  */
  187. typedef struct {
  188.  
  189.     LIST    table[LGNODEHASHTABLESIZE];
  190.     int        tableSize;
  191.     unsigned int    hashMask;
  192. } LGNODEHASHTABLE;
  193.  
  194.  
  195. /*
  196.  * Must define here since page.h isn't included until later.
  197.  */
  198. #define    EQUALPIDS(_a,_b)        \
  199.         ((_a).page  == (_b).page && (_a).volid == (_b).volid)
  200.  
  201.  
  202. /*
  203.  * Reset traversal stack.
  204.  */
  205. #define LG_ResetTstack(_tstack)        \
  206.     ((_tstack)->top = -1)
  207.  
  208.  
  209.  
  210. /*
  211.  * Boolean check for empty tstack.
  212.  */
  213. #define LG_EmptyTstack(_tstack)        \
  214.     ((_tstack)->top < 0)
  215.  
  216.  
  217.  
  218. /*
  219.  * See if top entry on tstack matches a given pid.
  220.  */
  221. #define LG_IsTopPid(_tstack, _pid)    \
  222.     (((_tstack)->top < 0)            \
  223.         ? FALSE                \
  224.         : (EQUALPIDS(*(_pid),(_tstack)->stack[(_tstack)->top].pid)))
  225.  
  226.  
  227. /*
  228.  * Get index of top stack entry.
  229.  */
  230. #define LG_TopTstackIndex(_tstack)    \
  231.     ((_tstack)->top)
  232.  
  233.  
  234. /*
  235.  *    Turn off printing routines if tracing is disabled
  236.  */
  237. #ifndef DEBUG
  238.  
  239. #define lg_PrintNode(arg1, arg2, arg3)
  240.  
  241. #define LG_PrintTstack(arg1)
  242.  
  243. #define lg_PrintIndex(arg1, arg2, arg3, arg4)
  244.  
  245. #endif
  246.  
  247.  
  248.  
  249. /*
  250.  * Error-handling macro (for debugging info, etc.)
  251.  */
  252. #define LG_ERRCHECK(_errVal)                                \
  253.                                                             \
  254.         if (_errVal < esmNOERROR) {                           \
  255.                                                             \
  256.             SM_ERROR(TYPE_WARNING, _errVal);                \
  257.         }
  258.  
  259. #endif /* _LGOBJECT_H_ */
  260.